#include <iostream>

#include "Implement_bai01.h"
#include "Implement_bai02.h"
#include "Implement_bai6_01.h"
#include "Implement_bai6_05.h"
#include "Implement_bai6_06.h"
#include "Implement_bai7_05.h"
#include "Implement_bai8_02.h"
#include "Implement_bai9_02.h"
#include "Implement_bai9_03.h"

using namespace std;

int main(){
	int selectSubNum = 0;
	std::cout<<"enter the number of question to implement : "; cin>>selectSubNum;
	std::cout<<"================================================================"<<endl;

	Student* stuArr = NULL;			// Khai bao con tro doi tuong bai01				case 3
	Student stu(10,20,'M',170,60);	// Khai bao doi tuong bai02						case 3
	Rectangle rec1, rec2(10, 20);	// Khai bao doi tuong bai6_05					case 4
	CStudent* pCStuent06 = NULL;	// Khai bao con tro doi tuong bai6_06			case 5
	Dyn_Student* pDynStu = NULL;	// Khai bao con tro doi tuong bai 7_05			case 6
	Vector* pVec = NULL;			// Khai bao con tro doi tuong bai 8_02			case 7
	Vector v1(5), v2(0), v3(5);		// Khai bao doi tuong bai8_02					case 7
	Circle* pC1 = NULL;				// Khai bao con tro doi tuong bai 8_02			case 8
	Cylinder* pCyliner = NULL;		// Khai bao con tro doi tuong bai 8_02			case 8
	Sphere* pSphere = NULL;			// Khai bao con tro doi tuong bai 8_02			case 8
	Regtangle* pRegtangle = NULL;	// Khai bao con tro doi tuong bai 8_02			case 9
	Box* pBox = NULL;				// Khai bao con tro doi tuong bai 8_02			case 9


	switch(selectSubNum){
	case 1:
		std::cout<<"bai 1 "<<endl
			<<"********************************"<<endl;

		int N;
		std::cout<<"enter N "; cin>>N;
		arrangeNum(N);
		std::cout<<N<<endl;

		break;
	case 2:
		std::cout<<"bai 2, tinh to hop C(n, m) "<<endl
			<<"********************************"<<endl;
		int n, m;
		do{
			std::cout<<"enter n and m : "; cin>>n>>m;
			if(m > n)
				std::cout<<"please enter again, m must less than n "<<endl;
		}while(m>n);
		
		std::cout<<"C("<<n<<", "<<m<<") = " <<toHopCnm(n, m);		

		break;
	case 3:
		std::cout<<"bai 6.1"<<endl
			<<"********************************"<<endl;

		int numberStudent;		
		std::cout<<"Nhap so student "; cin>>numberStudent;
		stuArr = new Student[numberStudent];

		for(int i = 0; i < numberStudent; i++){
			stuArr[i].getInfo();
		}
		std::cout<<endl;
		for(int i = 0; i < numberStudent; i++){
			stuArr[i].displayInfo();
			std::cout<<endl;
		}
		delete stuArr;
		stuArr = NULL;

		stu.displayInfo();

		break;
	case 4:
		std::cout<<"bai 6.5"<<endl
			<<"********************************"<<endl;

		rec1.getData();
		rec1.showData();
		std::cout<<"chu vi rec1 : "<<rec1.perimeter()<<endl;
		std::cout<<"dien tich rec1 : "<<rec1.area()<<endl;

		std::cout<<"chu vi rec2 : "<<rec2.perimeter()<<endl;
		std::cout<<"dien tich rec2 : "<<rec1.area()<<endl;
		
		break;
	case 5:
		std::cout<<"bai 6.6"<<endl
			<<"********************************"<<endl;
		pCStuent06 = new CStudent();
		pCStuent06->nhapMSSV();
		float diem;
		char w;
		do{
			cout<<"sinh vien nay con diem nhap nua khong ? nhap 'y' hoac 'Y' de tiep tuc"<<endl
				<<"neu khong nhap 'n' hoac 'N' : ";
			cin>>w;
			if(w != 'N' && w != 'n'){
				cout<<"nhap diem cho sinh vien "; cin>>diem;
				pCStuent06->upDateDiem(diem, pCStuent06->diemNums);
			}
		}while(w != 'N' && w != 'n');

		pCStuent06->xuatMssvDiemTB();
		delete pCStuent06;

		break;
	case 6:
		std::cout<<"bai 7.5"<<endl
			<<"********************************"<<endl;
		pDynStu = new Dyn_Student(3);
		pDynStu->nhapMssv();
		pDynStu->nhapCacDiemSo();
		pDynStu->showMssvDiemTB();
		pDynStu->~Dyn_Student();

		break;
	case 7:
		std::cout<<"bai 8.2"<<endl
			<<"********************************"<<endl;
		pVec = new Vector(3);
		pVec->showData();

		v1.showData();
		v2 = v1;
		v2.showData();
		
		v3.showData();
		v3.addVec(v1);
		v3.showData();
		v3.mulVec(v3, 5);
		v3.showData();
		pVec->~Vector();

	break;
	case 8:
		std::cout<<"bai 9.2"<<endl
			<<"********************************"<<endl;
		pC1 = new Circle(4);
		pC1->showCircle();

		pCyliner = new Cylinder(3, 10);
		pCyliner->showCylinder();

		pSphere = new Sphere(5);
		pSphere->showSphere();
		
		break;
	case 9:
		std::cout<<"bai 9.3"<<endl
			<<"********************************"<<endl;
		pRegtangle = new Regtangle(10, 20);
		pRegtangle->showRegtangle();

		pBox = new Box(10, 20, 30);
		pBox->showBox();
		break;
	}

	std::cout<<endl;
	return 0;	
}

